package com.wgu.modules.repository;

import com.wgu.entity.BookInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @Author: w
 * @Date: 2019/7/3 16:54
 * @Version 1.0
 */
@Repository
public interface BookRepository extends JpaRepository<BookInfo,Long>{

    /**
     * 查询全部起点书籍
     * @return
     */
    @Query(nativeQuery = true,value = "SELECT * FROM  qd_book")
    List<Map<String,Object>> findAllQDBook();

    /**
     * 根据书名及作者名称查询书籍
     * @param bookName
     * @param authorId
     * @return
     */
    Optional<BookInfo> findByBookNameAndAuthorId(String bookName, Long authorId);

    /**
     * 根据书名获取书籍
     * @param bookName
     * @return
     */
    BookInfo findByBookName(String bookName);
}
